<template>
  <div class="vipCharge-box">
    <nav-com :style="curIndex == 0 ? 'background:#3b3b4d;' : 'background:#231D1B'"
      :title="exp_time?'会员续费':'会员开通'"
      :showView="showView"
      @back="backHandler()"
    ></nav-com>
    <div class="header-box">
      <div
        :class="exp_time?'header-bg':'header-bg1'"
        :style="curIndex == 0 ? 'background:#3b3b4d;' : 'background:#231D1B'"
      >
        <div class="nav-bar">
          <!-- <div class="left-icon" @click="backHandler()">
            <img src="@/assets/vip/left-arr.png" />
          </div> -->
          <div class="nav-items">
            <div
              class="nav-item"
              :class="curIndex == 0 ? 'active' : ''"
              @click="tabChange(0)"
            >
              <img src="@/assets/vip/icon1.png" />会员版
              <div class="white-line"></div>
            </div>
            <div
              class="nav-item"
              :class="curIndex == 1 ? 'active' : ''"
              @click="tabChange(1)"
            >
              <img src="@/assets/vip/icon2.png" />升级版
              <div class="white-line"></div>
            </div>
          </div>
        </div>
        <div class="topTitle" v-if="!exp_time">
          开通即享两大权益
        </div>
        <div class="daoqi-box" :class="curIndex == 0 ? 'daoqitu1' : 'daoqitu2'"  v-if="exp_time">
          <div class="t0">会员到期时间</div>
          <div class="t1">{{exp_desc}}</div>
        </div>
      </div>
      <div class="vip-center">
        <div  class="card-item" :class="(item.enable==true&&index==selectInd)?'itemActive':item.enable==false?'itemDisabled':''" v-for="(item,index) in dataList" :key="index" @click="selectbox(item,index)">
          <div v-if="index==0" class="card-item1"> 
            <div class="t00">体验特价</div>
            <div class="t01">体验{{item.valid_day}}天</div>
            <div class="t02"><i>¥</i>{{item.price}}</div>
          </div>
          <div v-else>
            <div class="t0">{{item.valid_day}}天</div>
            <div class="t1">立省{{item.sub_price}}元</div>
            <div class="t2"><i>¥</i>{{item.price}}</div>
            <div class="t3">原价¥{{item.origin_price}}</div>
          </div>
        </div>
      </div>
    </div>
    <div class="chajian" v-if="exp_time">
      根据会员版的有效期，开通升级版可减免<span style="color:#FA2C1E;">¥{{selectData.jianmian}}</span>
    </div>
    <div class="open-btn" @click="openVip">
      <van-button block type="danger" v-if="curIndex == 0">
        {{!exp_time?'立即开通':'立即续费'}}
      </van-button>
      <van-button block type="primary" class="btnStyle" v-else>
        {{!exp_time?'补差价开通升级版（减免¥'+selectData.jianmian+'）':'补差价续费升级版（减免¥'+selectData.jianmian+'）'}}
      </van-button>
    </div>
    <!-- 两大权益 -->
    <div class="rights-box">
      <div class="title">两大权益</div>
      <div class="rights-list">
        <div class="list-item">
          <img
            src="@/assets/vip/team-icon.png"
            class="left"
            v-if="curIndex == 0"
          />
          <img src="@/assets/vip/team-icon1.png" class="left" v-else />
          <div class="right">
            <div class="t0">单聊主动</div>
            <div class="t1">{{selectData&&selectData.single==null?'不限':selectData.single+'个'}}</div>
          </div>
        </div>
        <div class="list-item">
          <img
            src="@/assets/vip/team-icon.png"
            class="left"
            v-if="curIndex == 0"
          />
          <img src="@/assets/vip/team-icon1.png" class="left" v-else />
          <div class="right">
            <div class="t0">群聊</div>
            <div class="t1">{{selectData&&selectData.group==null?'不限':selectData.group+'个'}}</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import navCom from "@/component/nav";
import Loading from "@/component/loading";
import { Popup, Toast } from "vant";
// import { Icon } from "vant";
import Upgrade from "@/component/upgrade.vue";
import { viplist,exp_notice} from "@/api/api";
export default {
  name: "index",
  components: {
    navCom,
    Loading,
    Upgrade,
  },
  data() {
    return {
      showView: true,
      LOADING: true,
      curIndex: 0,
      dataList: [],
      dataList1: [],
      dataList2: [],
      exp_time:false,
      exp_desc:'',
      selectData:{},
      selectInd:0
    };
  },
  created() {
    this.queryviplist(0);
    this.queryviplist(1);
  },
  mounted(){},
  methods: {
    //返回
    backHandler() {
      if (weixin.isAndroid()) {
        window.JS_TROOPS.goBack();
      } else {
        this.$router.go(-1);
      }
    },
    queryviplist(type) {
      this.dataList=[]
      //会员类型:0=会员版,1=升级版
      viplist({ vip_type:type }).then((res) => {
        if (res.data.code == 1) {
          this.exp_time=res.data.data.exp_time?true:false
          if(this.exp_time){
            this.exp_desc=res.data.data.exp_time
          }
          if(type==0){
            this.dataList1 = res.data.data.list;
            this.selectInd=this.dataList1[0]
          }
          if(type==1){
            this.dataList2 = res.data.data.list;
            this.selectInd=this.dataList2[0]
          }
          this.dataList=this.dataList1
          this.selectData=this.dataList[0]
        }
      });
    },
    selectbox(item,ind){
      if(item.enable){
        this.selectData=item
        this.selectInd=ind
      }
    },
    openVip() {
      localStorage.setItem("selectvipData",JSON.stringify(this.selectData))
        this.$router.push({
          name: "vipPay",
          params: this.selectData,
        });
    },
    tabChange(index) {
      this.selectInd=0;
      this.curIndex = index;
      this.dataList=[]
      if(this.curIndex==0){
        this.dataList=this.dataList1 
      }else if(this.curIndex==1){
         this.dataList=this.dataList2
      }
      this.selectData=this.dataList[0]
    },
  },
};
</script>
<style scoped>
.vipCharge-box {
  background: #f8f8f8;
  height: 100vh;
}
.header-bg {
  height: 176px;
}
.header-bg1 {
  height: 136px;
}
.nav-bar {
  width: 100vw;
  height: 13.33vw;
  line-height: 13.33vw;
  display: flex;
}
.left-icon {
  width: 20vw;
  margin: 1.33vw 0 0 3vw;
}
.left-icon img {
  width: 2.9vw;
  height: 5.8vw;
}
.nav-items {
  display: flex;
  justify-content: space-evenly;
  width: 100%;
}
.nav-item {
  font-size: 13px;
  font-family: Helvetica;
  color: #acacb4;
  display: flex;
  align-items: center;
}
.nav-item.active {
  position: relative;
}
.nav-item.active .white-line {
  width: 12px;
  height: 3px;
  background: linear-gradient(76deg, #f7edec 0%, #fde5dd 100%);
  border-radius: 2px;
  position: absolute;
  bottom: 5px;
  left: 50%;
}
.nav-item img {
  width: 12px;
  height: 12px;
  margin-right: 4px;
}
.topTitle{
  font-size: 13px;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: #F7E0DA;
  line-height: 20px;
  padding: 20px;
}
.daoqi-box t2{
  color:rgba(255,255,255,0.6);
}
.daoqitu1 {
  background: url("../../assets/vip/daoqi.png") no-repeat;
  background-size: 100% 86px;
  padding: 15px 26px;
  margin: 10px 8px;
  font-size: 13px;
    font-family: PingFangSC-Medium, PingFang SC;
    font-weight: 500;
    color: #FFFFFF;
    line-height: 20px;
    height: 76px;
}
.daoqitu2 {
  background: url("../../assets/vip/daoqi1.png") no-repeat;
  background-size: 100% 66px;
  padding: 10px 20px;
  margin: 10px 15px;
   font-size: 13px;
    font-family: PingFangSC-Medium, PingFang SC;
    font-weight: 500;
    color: #FFFFFF;
    line-height: 20px;
    height: 66px;
}
.vip-center {
  padding-left: 15px;
  /* overflow-x: scroll; */
  width: 100%;
  overflow: hidden;
  height: 146px;
  margin-top: -30px;
}
.vip-center .card-item {
  width: 27vw;
  height: 126px;
  background: #ffffff;
  border-radius: 8px;
  border: 1px solid #eeeeee;
  text-align: center;
  float: left;
  margin-right: 8px;
  margin-bottom: 20px;
}
.itemActive {
  box-shadow: 0px 2px 10px 0px rgba(253, 77, 31, 0.2);
  border-color: #ddc780!important;
}
.itemDisabled{
  background: #e2e2e2!important;
  border-color: #e2e2e2!important;
}
.itemDisabled .card-item1 .t00,.itemDisabled.card-item div .t1{
  background: #f5f5f5!important;
}
.itemDisabled .card-item1 .t02,.itemDisabled .card-item1 .t00,.itemDisabled.card-item div .t1{
  color: #000000!important;
}
.card-item .t0 {
  line-height: 24px;
  background: #f8f8f8;
  border-radius: 8px 8px 0px 0px;
  border: 1px solid #eeeeee;
  font-size: 13px;
  font-family: PingFangSC-Medium, PingFang SC;
  font-weight: 500;
  color: #000000;
}
.card-item .t1 {
  width: 60px;
  line-height: 22px;
  background: #fa2c1e;
  border-radius: 4px;
  font-size: 12px;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: #ffffff;
  margin: 8px auto 4px;
}
.card-item .t2 {
  font-size: 22px;
  font-family: PingFangSC-Medium, PingFang SC;
  font-weight: 500;
  color: #000000;
  line-height: 36px;
}
.card-item .t2 i {
  color: #000000;
  font-size: 12px;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  line-height: 20px;
  font-style: initial;
  margin-right: 3px;
}
.card-item .t3 {
  font-size: 12px;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: #cccccc;
  line-height: 20px;
}
.card-item1 .t00 {
  width: 66px;
  height: 20px;
  background: linear-gradient(153deg, #be4702 0%, #893003 100%);
  border-radius: 8px 0px 8px 0px;
  font-size: 11px;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: #ffffff;
  line-height: 17px;
  margin: -1px;
}
.card-item1 .t01 {
  font-size: 14px;
  font-family: PingFangSC-Medium, PingFang SC;
  font-weight: 500;
  color: #000000;
  line-height: 21px;
  margin: 15px auto 2px;
}
.card-item1 .t02 {
  font-size: 22px;
  font-family: PingFangSC-Medium, PingFang SC;
  font-weight: 500;
  color: #be4702;
  line-height: 42px;
}
.card-item1 .t02 i {
  font-size: 12px;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: #be4702;
  line-height: 20px;
  font-style: initial;
  margin-right: 3px;
}
.open-btn {
  margin: 0 15px;
}
.open-btn .van-button {
  border-radius: 4px;
}
.open-btn .btnStyle {
  background: linear-gradient(90deg, #493a1e 0%, #493a1e 100%);
  color: #feefbf;
  border: none;
  font-size: 14px;
}
.rights-box {
  width: calc(100% - 60px);
  height: 213px;
  background: #ffffff;
  box-shadow: 0px 2px 10px 0px rgb(0 0 0 / 5%);
  border-radius: 8px;
  margin: 30px 15px;
  padding: 15px;
}
.rights-box .title {
  font-size: 13px;
  font-family: PingFangSC-Medium, PingFang SC;
  color: #000000;
  font-weight: 600;
  line-height: 21px;
}
.rights-list {
  display: flex;
}
.rights-list .list-item {
  background: #f7f7f7;
  border-radius: 4px;
  padding: 15px 12px;
  display: flex;
  align-items: center;
  flex: 1;
}
.rights-list .list-item:first-child {
  margin-right: 11px;
}
.rights-list .list-item .left {
  width: 30px;
  height: 26px;
  margin-right: 6px;
}
.rights-list .list-item .right .t0 {
  font-size: 14px;
  font-family: PingFangSC-Medium, PingFang SC;
  font-weight: 500;
  color: #222222;
  line-height: 20px;
}
.rights-list .list-item .right .t1 {
  font-size: 11px;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: #6d7380;
  line-height: 16px;
}
.vip-tankbg {
  background: rgba(0, 0, 0, 0.75);
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  bottom: 0;
}
.vip-tankbg .vip-tank {
  background: url("../../assets/vip/tankbg.png") no-repeat;
  background-size: 100% 186px;
  margin: 50% 25px 0;
  height: 186px;
  padding: 24px 20px;
}
.vip-tankbg .vip-tank .t0 {
  font-size: 15px;
  font-family: PingFangSC-Medium, PingFang SC;
  font-weight: 550;
  color: #000000;
  line-height: 24px;
}
.t0-line {
  width: 40px;
  height: 4px;
  background: #493a1e;
  margin-top: 6px;
}
.vip-tankbg .vip-tank .t1 {
  font-size: 14px;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: #333333;
  line-height: 21px;
  margin: 20px 0 26px;
}
.vip-tankbg .vip-tank .t2 {
  width: 135px;
  background: #493a1e;
  border-radius: 4px;
  font-size: 14px;
  font-family: PingFangSC-Medium, PingFang SC;
  font-weight: 500;
  color: #ffffff;
  line-height: 40px;
  text-align: center;
  margin: 0 auto;
}
.vip-tankbg .tank-close {
  margin: 0 auto;
  width: 30px;
  height: 30px;
}
.vip-tankbg .tank-close img {
  width: 30px;
  height: 30px;
}
.chajian{
  font-size: 13px;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #222222;
line-height: 21px;
margin: 15px;
}
</style>